package com.appwoo.txtws.bean;

import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import java.io.PrintStream;

public class ApnUtils
{
  private static final String COLUMN_APN = "apn";
  private static final String COLUMN_APN_ID = "apn_id";
  private static final String COLUMN_ID = "_id";
  private static final String COLUMN_TYPE = "type";
  private static final Uri CURRENT_APNS = Uri.parse("content://telephony/carriers/current");
  private static final String MMS = "mms";
  private static final Uri PREFERRED_APN = Uri.parse("content://telephony/carriers/preferapn");
  private static final String[] PROJECTION = { "_id", "apn", "type" };
  private static final String SUFFIX_APN = "_suffix_apn";

  private static String addModifier(String paramString)
  {
    return paramString + "_suffix_apn";
  }

  private static String getAdaptedValue(String paramString, boolean paramBoolean)
  {
    if (paramString == null)
      if (!paramBoolean);
    do
    {
      return paramString;
      return "_suffix_apn";
      paramString = removeModifiers(paramString);
    }
    while (paramBoolean);
    return addModifier(paramString);
  }

  public static boolean getApnState(Context paramContext)
  {
    ContentResolver localContentResolver = paramContext.getContentResolver();
    int i = 0;
    Cursor localCursor = null;
    while (true)
    {
      try
      {
        localCursor = localContentResolver.query(CURRENT_APNS, PROJECTION, null, null, null);
        int j = localCursor.getColumnIndex("type");
        localCursor.moveToNext();
        boolean bool1 = localCursor.isAfterLast();
        if (bool1)
        {
          if (localCursor != null)
            localCursor.close();
          if (i != 0)
            return true;
        }
        else
        {
          String str = localCursor.getString(j);
          boolean bool2 = isDisabled(str);
          if (bool2)
            return false;
          if ((!isMms(str)) || (shouldDisableMms()))
            break label147;
          localCursor.moveToNext();
          continue;
        }
      }
      finally
      {
        if (localCursor != null)
          localCursor.close();
      }
      return false;
      label147: i++;
    }
  }

  private static boolean isDisabled(String paramString)
  {
    return (paramString != null) && (paramString.endsWith("_suffix_apn"));
  }

  private static boolean isMms(String paramString)
  {
    return (paramString != null) && (paramString.toLowerCase().endsWith("mms"));
  }

  private static String removeModifiers(String paramString)
  {
    if (paramString.endsWith("_suffix_apn"))
      paramString = paramString.substring(0, paramString.length() - "_suffix_apn".length());
    return paramString;
  }

  public static void setApnState(Context paramContext, boolean paramBoolean)
  {
    boolean bool1 = shouldDisableMms();
    ContentResolver localContentResolver = paramContext.getContentResolver();
    ContentValues localContentValues = new ContentValues();
    Cursor localCursor = null;
    String[] arrayOfString = new String[1];
    try
    {
      localCursor = localContentResolver.query(CURRENT_APNS, PROJECTION, null, null, null);
      i = localCursor.getColumnIndex("_id");
      j = localCursor.getColumnIndex("apn");
      int k = localCursor.getColumnIndex("type");
      localCursor.moveToFirst();
      while (true)
      {
        boolean bool2 = localCursor.isAfterLast();
        if (bool2)
          return;
        str = localCursor.getString(k);
        if ((paramBoolean) || (!isMms(str)) || (bool1))
          break;
        localCursor.moveToNext();
      }
    }
    catch (Exception localException)
    {
      while (true)
      {
        int i;
        int j;
        String str;
        return;
        System.out.println(getAdaptedValue(localCursor.getString(j), paramBoolean) + "  22");
        System.out.println(getAdaptedValue(str, paramBoolean) + "  44");
        System.out.println(String.valueOf(localCursor.getInt(i)) + " 55");
        arrayOfString[0] = String.valueOf(localCursor.getInt(i));
        localContentValues.put("apn", getAdaptedValue(localCursor.getString(j), paramBoolean));
        localContentValues.put("type", getAdaptedValue(str, paramBoolean));
        localContentResolver.update(CURRENT_APNS, localContentValues, "_id=?", arrayOfString);
        localCursor.moveToNext();
      }
    }
    finally
    {
      if (localCursor != null)
        localCursor.close();
    }
  }

  private static boolean shouldDisableMms()
  {
    return false;
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.bean.ApnUtils
 * JD-Core Version:    0.6.2
 */